from fastapi import APIRouter
from pydantic import BaseModel


class ControlResourceRequest(BaseModel):
    resourceId: str  # 唯一标识
    targetPower: int  # 控制数据
    startTime:str
    endTime:str


def create_router(handler):
    router = APIRouter(tags=["control"])

    @router.post("/control")
    def control(payload: ControlResourceRequest):
        """
        控制设备
        """
        return handler(payload)

    return router
